﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TimsBaseComponents
{
   public class chekBox : DevExpress.XtraEditors.CheckEdit
    {
       public delegate void MetaDataDelegate(object MetaDataValue);
       public event MetaDataDelegate OnMetaDataChanged;
       private bool Clicked;

       private object _MetaData=DBNull.Value;
       public object MetaData
       {
           get
           {
              return _MetaData;
           }
           set
           {               
               _MetaData = value;
               if (OnMetaDataChanged != null && Clicked==false)
               {
                   if (value == DBNull.Value)
                   {                       
                       OnMetaDataChanged(0);                 
                   }
                   else
                   {
                       if (Convert.ToInt16(value) == 0)
                       {
                           OnMetaDataChanged(1);
                       }
                       else
                       {
                           OnMetaDataChanged(value);
                       }
                   }                   
               }
               Clicked = false;         
           }
       }

       protected override void OnClick(EventArgs e)
       {
           Clicked = true;
           base.OnClick(e);
       } 

       
    }
}
